﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel.Composition;

namespace Kooboo.Commerce.Repositories
{
    [Export(typeof(ISubTax))]
    partial class SubTax:Entity, ISubTax
    {
        #region ISubTax Members

        ICountry country;
        ICountry ISubTax.Country
        {
            get
            {
                if (this.country == null)
                {
                    this.country = this.DataContext.Countries
                        .Where(i => i.CountryCode == this.CountryCode)
                        .OfType<ICountry>()
                        .FirstOrDefault();
                }

                return this.country;
            }
            set
            {
                this.country = value;
                this.CountryCode = value==null?null:value.CountryCode;
            }
        }

        #endregion
    }
}
